package com.learn.threadpool;

import com.learn.constant.MathConstant;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * NewFixedThreadPool
 *
 * 创建一个定长线程池，可控制线程最大并发数，超出的线程会在队列中等待
 }
 */
public class NewFixedThreadPoolTest {

    public static void main(String[] args) {

        ExecutorService service = Executors.newFixedThreadPool(MathConstant.INT_FIVE);

        for (int i = MathConstant.INT_ZERO; i < MathConstant.INT_20; i ++) {
            service.execute(new MyThread(i));
        }

    }

}
